package IO_study.transferStream;

import java.io.*;

public class OutputStreamWriterDemo {
    public static void main(String[] args) throws Exception{
        // 1.定义一个字节输出流
        OutputStream os = new FileOutputStream("E:\\Project-IDEA\\Study_java\\Java-basic\\src\\IO_study\\gbkData02.txt");

        // 2.把原始字节输出流转换成字符输出流
//        OutputStreamWriter osw = new OutputStreamWriter(os); // 默认的UTF-8写出去
        OutputStreamWriter osw = new OutputStreamWriter(os, "GBK"); // 指定GBK编码方式写出去

        // 3.把字符输出流包装成高级的缓冲字符输出流
        BufferedWriter bw = new BufferedWriter(osw);

        bw.write("nanako");
        bw.write("nanako奈奈子");

        bw.close();

    }
}
